<template>
  <div class="rent">
    <header>
      <van-icon name="arrow-left" @click="$router.go(-1)" />
      <h3>房屋管理</h3>
      <i></i>
    </header>
    <main>
      <div class="dls">
        <dl v-for="(its, ind) in manger" :key="ind">
          <dt>
            <img :src="its.houseImg" alt="" />
          </dt>
          <dd>
            <h3 @click="goDetail(its.houseCode)">{{ its.title }}</h3>
            <p>{{ its.desc }}</p>
            <span
              ><b>{{ its.price }}</b
              >元/月</span
            >
          </dd>
        </dl>
      </div>
    </main>
  </div>
</template>

<script>
import {mapState} from 'vuex'
import axios from "axios";
export default {
  data() {
    return {
      manger: [],
    }
  },
   computed: {
    ...mapState(["city"]),
  },
  created() {
    axios.get(`/houses?cityId=${this.city.value}`).then((res) => {
      console.log(res, "houses");
      this.manger = res.data.body.list;
    })
  },
  methods:{
    goDetail(houseCode) {
      this.$router.push({ path: `/detail/${houseCode}` });
      console.log(houseCode, "码数");
    },
  }
};
</script>

<style lang='scss' scoped>
.rent {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  header {
    width: 100%;
    height: 1rem;
    border-bottom: 1px solid #eee;
    background-color: #f6f5f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.3rem;
    h3 {
      font-weight: normal;
    }
  }
}
main{
  flex: 1;
  overflow-y: scroll;
}
.dls {
  width: 100%;
  dl {
    width: 100%;
    height: 2.4rem;
    display: flex;
    align-items: center;
    padding: 0.2rem;
    border-bottom: 1px solid #eee;
    dt {
      width: 2.1rem;
      height: 100%;
      margin: 0 0.2rem;
      img {
        width: 2.1rem;
        height: 1.6rem;
      }
    }
    dd {
      flex: 1;
      h3 {
        font-size: 15px;
        letter-spacing: 0;
      }
      p {
        font-size: 12px;
        color: #afb2b3;
        padding: 0.2rem 0;
      }
      span {
        color: #fa5741;
      }
    }
  }
}
</style>